
local CommonOHOH = _G.CommonOHOH;
local M = CommonOHOH.class.new(script, script.Parent.base,script.Parent.Name);
local CallBackManager = CommonOHOH.load.CallBackManager();

function M.new(self,...)
	return M(self,...);
end;

function M.ctor(self, parent)
	M.super.ctor(self, parent);
	self:initTeleport()
end;

function M.dtor(self)
	M.super.dtor(self);
end;

local InstanceManager = _G.ClientOHOH.load.InstanceManager();

function M.initTeleport(self)
    self.SkyCtrl=  _G.client.local_player:GetComponent(_G.ClientOHOH.load.Client_SkyComponent())

	local enter=CommonOHOH:GetPath_Loop("Teleport.Enter.Touch",self.BattleInst)
	CallBackManager:AddRbxConnect(self,enter.Touched, function(obj,chPart)
		 if  _G.CommonOHOH.load.GeneralTool().IsMeTouchEvent(chPart) then
			local p= chPart:FindFirstAncestorOfClass("Model")
			local character = InstanceManager:FindObject(p);

			character:SetCFrame(enter.go.WorldCFrame)
			 local skyFolder=self:GetSkyFolder()
			 if #skyFolder:GetChildren()>0 then
				self.SkyCtrl:SetSky(skyFolder:Clone())
			 end
		 end

	end)

	local leave=CommonOHOH:GetPath_Loop("Teleport.Leave.Touch",self.BattleInst)
	CallBackManager:AddRbxConnect(self,leave.Touched, function(obj,chPart)
		 if  _G.CommonOHOH.load.GeneralTool().IsMeTouchEvent(chPart) then
			local p= chPart:FindFirstAncestorOfClass("Model")
			local character = InstanceManager:FindObject(p);

			character:SetCFrame(enter.go.WorldCFrame)
			 self.SkyCtrl:SetDefaultSky()
		 end

	end)

end


return M
